|
|
|
|
|
|
|
End
Exit Sub
End Sub
Sub CreateTable(ByRef tbl As TableDef, sTableName As String, sINISection As _
String)
'This function creates an empty table in an Access database
Dim nFields As Integer 'Number of Fields
Dim Fd() As New Field 'Array of fields
Dim nCurField As Integer 'Counter for current field
Dim sTemp As String
On Error GoTo CRTError:
nFields = CInt(sGetINIString(sINIPath, sINISection, "Fields", "0"))
If nFields = 0 Then Exit Sub
ReDim Fd(1 To nFields)
tbl.Name = sTableName
For nCurField = 1 To nFields
Fd(nCurField).Name = sGetINIString_
(sINIPath, sINISection, "Fd" & nCurField & "Name", "ERROR" & _
nCurField)
sTemp = sGetINIString(sINIPath, sINISection, "Fd" & nCurField & "Type", _
"TEXT")
Select Case sTemp
Case "DOUBLE"
Fd(nCurField).Type = dbDouble
Case "MEMO"
Fd(nCurField).Type = dbMemo
'VB4/5 only
Fd(nCurField).AllowZeroLength = True
Case "BYTE"
Fd(nCurField).Type = dbByte
Case "INTEGER"
Fd(nCurField).Type = dbInteger
Case "DATE"
Fd(nCurField).Type = dbDate
Fd(nCurField).Required = False
Case Else 'Text
Fd(nCurField).Type = dbText
Fd(nCurField).Size = CInt(sGetINIString_
(sINIPath, sINISection, "Fd" & nCurField & "Size", "50"))
Fd(nCurField).AllowZeroLength = True
End Select
tbl.Fields.Append Fd(nCurField)
Next nCurField
Exit Sub |
|
|
|
|
|